<?php

class Core_Backend_Component_Foundation_View_Helper_Choose_Poi extends Core_Backend_Component_Foundation_View_Poi_Index {

    protected function buildToolbar($toolbar) {
        $group = $toolbar->createGroup('selector');
        $group->addButton($this->__('share.button.selectAll'))
                ->bindEvent('click', "Kdf.Ui.getGrid('choose_poi_grid').selectAll()");
        $group->addButton($this->__('share.button.cancelSelected'))
                ->bindEvent('click', "Kdf.Ui.getGrid('choose_poi_grid').cancelSelected()");
        $group->addButton($this->__('share.button.selectInverse'))
                ->bindEvent('click', "Kdf.Ui.getGrid('choose_poi_grid').selectInverse()");

        $group = $toolbar->createGroup('filter');
        $group->addButton($this->__('share.button.filter'))
              ->bindEvent('click', "Kdf.Ui.getForm('choose_poi_form').submit()");
        $group->addButton($this->__('share.button.clear_filter'))
              ->bindEvent('click', "clearForm()");
        $group = $toolbar->createGroup();
        $group->addButton($this->__('share.button.ok'))
              ->bindEvent('click', 'chooseMulti()');
    }

    public function buildGrid($grid) {
        $this->getTemplate()->assign('selected', $this->getSelected())
                            ->assign('element_id', $this->getElementId())
                            ->assign('is_self', $this->getIsSelf())
                            ->assign('callback', $this->getCallback())
                            ->assign('dialog_title', $this->getTitle())
                            ->assign('road', $this->getRoad())
                            ->assign('industry', $this->getIndustry());
        parent::buildGrid($grid);
        $grid->removeColumn('users');
        $grid->setId('choose_poi_grid')
             ->addButtonColumn('#', 'choose', 'returnChoose(this)', $this->__('share.button.choose'))
                ->setWidth(50)
                ->setAlign('center');
        if($this->getRoad()){
            $grid->getColumn('districtname')->removeFilter();
            $grid->getColumn('townstreetname')->removeFilter();
            $grid->getColumn('roadname')->removeFilter();
        }
    }
}

